home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / smail-3.1.28 / src / verify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-11  |  4.1 KB  |  148 lines

  1. /* @(#)src/verify.c    1.4 7/11/92 11:51:51 */
  2.  
  3. /*
  4.  *    Copyright (C) 1987, 1988 Ronald S. Karr and Landon Curt Noll
  5.  *    Copyright (C) 1992  Ronald S. Karr
  6.  * 
  7.  * See the file COPYING, distributed with smail, for restriction
  8.  * and warranty information.
  9.  */
  10.  
  11. /*
  12.  * verify.c:
  13.  *    address verification functions and user interfaces for address
  14.  *    verification and expansion.
  15.  *
  16.  *    external functions: verify_addr_list
  17.  */
  18. #include <stdio.h>
  19. #include "defs.h"
  20. #include "smail.h"
  21. #include "dys.h"
  22. #include "addr.h"
  23. #include "direct.h"
  24. #include "route.h"
  25. #ifndef DEPEND
  26. # include "extern.h"
  27. # include "debug.h"
  28. # include "error.h"
  29. #endif
  30.  
  31.  
  32. /*
  33.  * verify_addr_list - verify deliverability to a set of addresses
  34.  *
  35.  * call upon the verify entry points to the director and router drivers
  36.  * to perform simple verification for a list of addresses.
  37.  *
  38.  * For directors, verification is only one level deep; i.e., if any
  39.  * director matches a local address, the address verifies true.
  40.  *
  41.  * An error structure is stored in the error fields for entries in the
  42.  * defer and fail output lists.  Only work_addr, target and remainder are
  43.  * set in the okay output list.  If it is desired that work_addr be
  44.  * restored back to the original value, it is the callers responsibility
  45.  * to arrange this.
  46.  *
  47.  * The first router that finds a match for a target wins, as we do not
  48.  * need to actually determine who has the best match, we only need to know
  49.  * if a match exists.
  50.  */
  51. void
  52. verify_addr_list(in, okay, defer, fail)
  53.     struct addr *in;            /* input addr list */
  54.     struct addr **okay;            /* output list of verified addrs */
  55.     struct addr **defer;        /* temporariliy unverifiable addrs */
  56.     struct addr **fail;            /* unverified addrs */
  57. {
  58.     register struct addr *cur;        /* current address being processed */
  59.     struct addr *next;            /* next address to process */
  60.     struct addr *local;            /* addrs that parsed local */
  61.     struct addr *remote;        /* addrs that parsed remote */
  62.  
  63.     /*
  64.      * form the local and remote lists, and put parse errors into fail.
  65.      */
  66.     remote = NULL;
  67.     local = NULL;
  68.     for (cur = in; cur; cur = next) {
  69.     int form;            /* form from parse_address() */
  70.  
  71.     next = cur->succ;
  72.  
  73.     /* get the form, plus the target and remainder */
  74.     form = parse_address(cur->work_addr, &cur->target, &cur->remainder,
  75.                  &cur->parseflags);
  76.  
  77.     /* split into lists based on the form */
  78.     switch (form) {
  79.     case FAIL:
  80.     case PARSE_ERROR:
  81.         /*
  82.          * ERR_111 - address parse error
  83.          *
  84.          * DESCRIPTION
  85.          *      parse_address() encountered an error while parsing the
  86.          *      work_addr for this address.  The error is stored in
  87.          *      cur->remainder.
  88.          *
  89.          * ACTIONS
  90.          *      A message about the parse error should be returned to
  91.          *      the owner of the address or to the sender.
  92.          *
  93.          * RESOLUTION
  94.          *      The owner or sender should correct the address and
  95.          *      resubmit the message.
  96.          */
  97.         cur->error = note_error(ERR_NSOWNER|ERR_111,
  98.                     xprintf("address parse error: %s",
  99.                         cur->remainder));
  100.         cur->flags |= PARSE_ERROR;
  101.         cur->succ = *fail;
  102.         *fail = cur;
  103.         break;
  104.  
  105.     case LOCAL:
  106.         /*
  107.          * a local form in quotes must be reparsed,
  108.          * otherwise put it on the local addr list.
  109.          */
  110.         if (strip(cur->remainder)) {
  111.         /* it was in quotes, put it back on the input */
  112.         cur->work_addr = cur->remainder;
  113.         next = cur;
  114.         } else {
  115.         cur->succ = local;
  116.         local = cur;
  117.         }
  118.         break;
  119.  
  120.     default:
  121.         /*
  122.          * a remote form may point to the local host, if so
  123.          * put it back on the input, otherwise it goes on the
  124.          * remote list.
  125.          */
  126.         if (islocalhost(cur->target)) {
  127.         /* it is the local host, parse it again */
  128.         cur->work_addr = cur->remainder;
  129.         next = cur;
  130.         } else {
  131.         cur->succ = remote;
  132.         remote = cur;
  133.         }
  134.         break;
  135.     }
  136.     }
  137.  
  138.     /* if there are any local addrs, run them through the directors */
  139.     if (local) {
  140.     verify_local_addrs(local, okay, defer, fail);
  141.     }
  142.  
  143.     /* if there are any remote addrs, run them through the routers */
  144.     if (remote) {
  145.     verify_remote_addrs(remote, okay, defer, fail);
  146.     }
  147. }
  148.